package com.artpri.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.artpri.model.UserInfo;
import com.artpri.service.ActionService;
import com.artpri.service.AdPictureService;
import com.artpri.service.AttentionCenterService;
import com.artpri.service.DeliverAddService;
import com.artpri.service.EmailService;
import com.artpri.service.GoodAttributeService;
import com.artpri.service.GoodsAlbumService;
import com.artpri.service.GoodsAttrService;
import com.artpri.service.GoodsCategoryService;
import com.artpri.service.GoodsCommentService;
import com.artpri.service.GoodsFilterService;
import com.artpri.service.GoodsService;
import com.artpri.service.OrderInfoService;
import com.artpri.service.ShoppingCartService;
import com.artpri.service.UserService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

/**
 * 本类为action的基类,该类中注册了所有的Service层中的Service类
 * 其他的Action需要继承自这个基类以获得spring对其中注入的bean
 * @author 王校兵
 * @version 1.0， 2016-2-28
 */
public class BaseAction extends ActionSupport{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -5521110961881837756L;
	
	private GoodAttributeService    goodAttributeService;
	private GoodsFilterService      goodsFilterService;
	private GoodsCategoryService	goodsCategoryService;
	private GoodsService            goodsService;
	private GoodsAlbumService       goodsAlbumService;
	private GoodsAttrService        goodsAttrService;
	private GoodsCommentService     goodsCommentService;
	private ShoppingCartService     shoppingCartService;
	private AttentionCenterService  attentionCenterService;
	private UserService             userService;
	private EmailService			emailService;
	private DeliverAddService       deliverAddService;
	private OrderInfoService		orderInfoService;
	private AdPictureService        adPictureService;
	private ActionService           actionService;
	
	
	public ActionService getActionService() {
		return actionService;
	}

	public void setActionService(ActionService actionService) {
		this.actionService = actionService;
	}

	public ShoppingCartService getShoppingCartService() {
		return shoppingCartService;
	}

	public void setShoppingCartService(ShoppingCartService shoppingCartService) {
		this.shoppingCartService = shoppingCartService;
	}

	public AttentionCenterService getAttentionCenterService() {
		return attentionCenterService;
	}

	public void setAttentionCenterService(
			AttentionCenterService attentionCenterService) {
		this.attentionCenterService = attentionCenterService;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public EmailService getEmailService() {
		return emailService;
	}

	public void setEmailService(EmailService emailService) {
		this.emailService = emailService;
	}

	public DeliverAddService getDeliverAddService() {
		return deliverAddService;
	}

	public void setDeliverAddService(DeliverAddService deliverAddService) {
		this.deliverAddService = deliverAddService;
	}

	public OrderInfoService getOrderInfoService() {
		return orderInfoService;
	}

	public void setOrderInfoService(OrderInfoService orderInfoService) {
		this.orderInfoService = orderInfoService;
	}

	public AdPictureService getAdPictureService() {
		return adPictureService;
	}

	public void setAdPictureService(AdPictureService adPictureService) {
		this.adPictureService = adPictureService;
	}

	public GoodAttributeService getGoodAttributeService() {
		return goodAttributeService;
	}

	public void setGoodAttributeService(GoodAttributeService goodAttributeService) {
		this.goodAttributeService = goodAttributeService;
	}

	public GoodsFilterService getGoodsFilterService() {
		return goodsFilterService;
	}

	public void setGoodsFilterService(GoodsFilterService goodsFilterService) {
		this.goodsFilterService = goodsFilterService;
	}

	public GoodsCategoryService getGoodsCategoryService() {
		return goodsCategoryService;
	}

	public void setGoodsCategoryService(GoodsCategoryService goodsCategoryService) {
		this.goodsCategoryService = goodsCategoryService;
	}

	public GoodsService getGoodsService() {
		return goodsService;
	}

	public void setGoodsService(GoodsService goodsService) {
		this.goodsService = goodsService;
	}

	public GoodsAlbumService getGoodsAlbumService() {
		return goodsAlbumService;
	}

	public void setGoodsAlbumService(GoodsAlbumService goodsAlbumService) {
		this.goodsAlbumService = goodsAlbumService;
	}

	public GoodsAttrService getGoodsAttrService() {
		return goodsAttrService;
	}

	public void setGoodsAttrService(GoodsAttrService goodsAttrService) {
		this.goodsAttrService = goodsAttrService;
	}

	public GoodsCommentService getGoodsCommentService() {
		return goodsCommentService;
	}

	public void setGoodsCommentService(GoodsCommentService goodsCommentService) {
		this.goodsCommentService = goodsCommentService;
	}

	protected Map<String, Object> getSession() {
		return ActionContext.getContext().getSession();
	}

	protected UserInfo getSessionUser() {
		return (UserInfo) getSession().get("user");
		//return new UserInfo(100001,"齐梦慧","13931991859","qimenghui@126.com","D9840773233FA6B19FDE8CAF765402F5",3,"齐梦慧","男","河北乐亭人","http://img.zscaling.xyz:8080/shop/2016-08-14_105253.png","1");
	}

	protected HttpServletRequest getRequest() {
		return ServletActionContext.getRequest();
	}

	protected PrintWriter getWriter() throws IOException {
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setContentType("application/json; charset=utf-8");
		response.setHeader("cache-control", "no-cache");
		return response.getWriter();
	}
}
